package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.RepairMapper;
import com.ruoyi.system.domain.Repair;
import com.ruoyi.system.service.IRepairService;
import com.ruoyi.common.core.text.Convert;

/**
 * 小区报修信息Service业务层处理
 * 
 * @author 祖新宇
 * @date 2024-12-18
 */
@Service
public class RepairServiceImpl extends ServiceImpl<RepairMapper,Repair> implements IRepairService

{
    @Autowired
    private RepairMapper repairMapper;

    /**
     * 查询小区报修信息
     * 
     * @param id 小区报修信息主键
     * @return 小区报修信息
     */
    @Override
    public Repair selectRepairById(Long id)
    {
        return repairMapper.selectRepairById(id);
    }

    /**
     * 查询小区报修信息列表
     * 
     * @param repair 小区报修信息
     * @return 小区报修信息
     */
    @Override
    public List<Repair> selectRepairList(Repair repair)
    {
        return repairMapper.selectRepairList(repair);
    }

    /**
     * 新增小区报修信息
     * 
     * @param repair 小区报修信息
     * @return 结果
     */
    @Override
    public int insertRepair(Repair repair)
    {
        repair.setCreateTime(DateUtils.getNowDate());
        return repairMapper.insertRepair(repair);
    }

    /**
     * 修改小区报修信息
     * 
     * @param repair 小区报修信息
     * @return 结果
     */
    @Override
    public int updateRepair(Repair repair)
    {
        repair.setUpdateTime(DateUtils.getNowDate());
        return repairMapper.updateRepair(repair);
    }

    /**
     * 批量删除小区报修信息
     * 
     * @param ids 需要删除的小区报修信息主键
     * @return 结果
     */
    @Override
    public int deleteRepairByIds(String ids)
    {
        return repairMapper.deleteRepairByIds(Convert.toStrArray(ids));
    }

    /**
     * 批量软删除小区报修信息
     *
     * @param ids 需要软删除的小区报修信息主键
     * @return 结果
     */
    @Override
    public int softDeleteRepairByIds(String ids)
    {
        String[] strArray = Convert.toStrArray(ids);
        int count = 0;
        for (String s : strArray) {
            Repair repair = repairMapper.selectRepairById(Long.valueOf(s));
            repair.setIsDelete(1);
            int i = repairMapper.updateRepair(repair);
            count = count + i;
        }
        return count;
    }

    /**
     * 删除小区报修信息信息
     * 
     * @param id 小区报修信息主键
     * @return 结果
     */
    @Override
    public int deleteRepairById(Long id)
    {
        return repairMapper.deleteRepairById(id);
    }
}
